package com.zbkj.admin.controller.platform.assistant.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.zbkj.common.model.assistant.AssistantConversation;
import com.zbkj.common.model.assistant.AssistantGroup;
import com.zbkj.common.model.assistant.AssistantGroupAccount;
import com.zbkj.common.model.assistant.AssistantSetting;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.service.assistant.model.request.AssistantConversationCompleteRequest;
import com.zbkj.service.assistant.model.request.AssistantConversationHistorySearchRequest;
import com.zbkj.service.assistant.model.request.AssistantConversationSearchRequest;
import com.zbkj.service.assistant.model.vo.AssistantConversationVO;

import java.util.List;

/**
* @author keNan
* @description AssistantConversationService 接口
* @date 2025-06-11
*/
public interface AssistantConversationService extends IService<AssistantConversation> {

    /**
     * 更新转接会话
     */
    AssistantConversation updateTransfer(AssistantConversation conversation, AssistantGroupAccount toAccount);

    /**
     * 获取历史会话列表
     */
    PageInfo<AssistantConversationVO> getAdminConversationHistoryPage(AssistantConversationHistorySearchRequest request, PageParamRequest pageParamRequest);

    /**
     * 添加消息数量
     * @param conversationId 会话id
     * @param userCount 用户消息数量
     * @param serviceCount 服务消息数量
     */
    void updateAddMsgCount(Integer conversationId, Integer userCount, Integer serviceCount);

    /**
     * 获取进行中的会话列表
     * @return
     */
    List<AssistantConversation> findServiceList();

    /**
     * 处理排队的队列
     * @param setting 客服配置
     * @param conversation 排队的会话
     * @return 是否成功转换到服务中
     */
    Boolean processQueue(AssistantSetting setting, AssistantConversation conversation);

    /**
     * 管理员获取进行中的会话列表
     * @param request
     * @return
     */
    List<AssistantConversationVO> getAdminConversationList(AssistantConversationSearchRequest request);

    /**
     * 会话修改为已完成
     */
    void complete(AssistantConversationCompleteRequest request);
    /**
     * 会话超时处理，修改为已完成
     * @param setting 设置
     * @param conversation 会话
     */
    void timeout(AssistantSetting setting, AssistantConversation conversation);
    /**
     * 获取排队的会话列表
     * @return
     */
    List<AssistantConversation> findQueueList();

    /**
     * 根据排队规则获取对应的服务人员ID
     * @param setting
     * @param codeEnum
     * @return
     */
    Integer checkServiceAccountId(AssistantSetting setting, AssistantGroup.CodeEnum codeEnum);
}